<template>
  <div>
    <cos-uploader v-if="!file" :label="label" @file-uploaded="onFileUpload"/>
     <div v-if="file">
       {{file.name +file.ext}}
       <q-btn @click="reUpload">重新上传</q-btn>
     </div>
  </div>
</template>

<script setup>
import CosUploader from "../composables/useCosUploader.js";

defineProps({
  label:{
    type:String,
    default:''
  },
  file:{
    type:Object,
    default(){
      return null
    }
  }
})

const emit=defineEmits(['update:file'])

const onFileUpload=file=>{
  emit('update:file',file)
}

const reUpload=()=>{
  emit('update:file',null)
}
</script>

<style scoped></style>